package com.huangfuyi.home.dao;

import com.huangfuyi.home.entity.BaiduDiskTokenEntity;
import org.apache.ibatis.annotations.*;

@Mapper
public interface BaiduDiskTokenDao {

    @Select("select " +
            "id,app_id,app_key,secret_key,sign_key,expires_in,access_token,refresh_token,update_time " +
            "from baidu_disk_token " +
            "where id = #{id}")
    @Results(id = "BaiduDiskTokenEntity", value = {
            @Result(column = "id", property = "id"),
            @Result(column = "app_id", property = "appId"),
            @Result(column = "app_key", property = "appKey"),
            @Result(column = "secret_key", property = "secretKey"),
            @Result(column = "sign_key", property = "signKey"),
            @Result(column = "expires_in", property = "expiresIn"),
            @Result(column = "access_token", property = "accessToken"),
            @Result(column = "refresh_token", property = "refreshToken"),
            @Result(column = "update_time", property = "updateTime"),
    })
    BaiduDiskTokenEntity queryById(String id);

    @Update("update baidu_disk_token set" +
            "expires_in = #{expiresIn}," +
            "access_token = #{accessToken}," +
            "refresh_token = #{refreshToken}," +
            "update_time = #{updateTime} " +
            "where id = #{id}")
    int update(BaiduDiskTokenEntity baiduDiskToken);
}
